package com.ssy.lingxi.order.controller.mobile;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderAgreeVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderIdVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobileVendorOrderPageVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobileVendorUpdateFreightVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobileVendorValidateOrderPageVO;
import com.ssy.lingxi.order.model.vo.mobile.response.MobileVendorOrderDetailVO;
import com.ssy.lingxi.order.model.vo.mobile.response.MobileVendorOrderQueryVO;
import com.ssy.lingxi.order.model.vo.mobile.response.MobileVendorValidateSubscriptVO;
import com.ssy.lingxi.order.model.vo.vendor.request.VendorUpdatePayRateVO;
import com.ssy.lingxi.order.service.mobile.IMobileVendorOrderService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu App - 业务员（销售）订单相关接口
 * @author wyx
 * @version 2.0.0
 * @date 2022-03-22
 **/
@RestController
@RequestMapping("/order/mobile/vendor")
public class MobileVendorOrderController {
    @Resource
    private IMobileVendorOrderService mobileVendorOrderService;


    /**
     * 查看绑定订单 - 分页查询订单
     * @param headers Http头部信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileVendorOrderQueryVO>> pageOrders(@RequestHeader HttpHeaders headers, @Valid MobileVendorOrderPageVO pageVO) {
        return mobileVendorOrderService.pageOrders(headers, pageVO);
    }

    /**
     * 查看绑定订单 - 订单详情
     * @param headers Http头部信息
     * @param idVO    接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<MobileVendorOrderDetailVO> getOrderDetail(@RequestHeader HttpHeaders headers, @Valid OrderIdVO idVO) {
        return mobileVendorOrderService.getOrderDetail(headers, idVO);
    }

    /**
     * 订单审核 - 订单数量角标
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/subscripts", method = RequestMethod.GET)
    public Wrapper<List<MobileVendorValidateSubscriptVO>> getOrderSubscripts(@RequestHeader HttpHeaders headers) {
        return mobileVendorOrderService.getOrderSubscripts(headers);
    }

    /**
     * 订单审核 - 分页查询列表
     * @param headers Http头部信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileVendorOrderQueryVO>> pageValidateOrders(@RequestHeader HttpHeaders headers, @Valid MobileVendorValidateOrderPageVO pageVO) {
        return mobileVendorOrderService.pageValidateOrders(headers, pageVO);
    }

    /**
     * “待提交审核订单” - 查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/submit/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileVendorOrderQueryVO>> pageSubmitToConfirmOrders(@RequestHeader HttpHeaders headers, @Valid MobileVendorValidateOrderPageVO pageVO) {
        return mobileVendorOrderService.pageSubmitToConfirmOrders(headers, pageVO);
    }

    /**
     * “待提交审核订单” - 提交审核
     * @param headers Http头部信息
     * @param agreeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/submit", method = RequestMethod.POST)
    public Wrapper<Void> submitToConfirmOrder(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderAgreeVO agreeVO) {
        return mobileVendorOrderService.submitToConfirmOrder(headers, agreeVO);
    }

    /**
     * “分页查询订单列表、待提交审核订单” - 修改运费和商品价格
     * @param headers Http头部信息
     * @param freightVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/submit/freight/update", method = RequestMethod.POST)
    public Wrapper<Void> updateFreightAndProductPrices(@RequestHeader HttpHeaders headers, @RequestBody @Valid MobileVendorUpdateFreightVO freightVO) {
        return mobileVendorOrderService.updateFreightAndProductPrices(headers, freightVO);
    }

    /**
     * “待提交审核订单” - 修改支付比例
     * @param headers Http头部信息
     * @param payRateVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/submit/payment/update", method = RequestMethod.POST)
    public Wrapper<Void> updatePayRate(@RequestHeader HttpHeaders headers, @RequestBody @Valid VendorUpdatePayRateVO payRateVO) {
        return mobileVendorOrderService.updatePayRate(headers, payRateVO);
    }

    /**
     * “待审核订单（一级）” - 查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/grade/one/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileVendorOrderQueryVO>> pageToValidateGradeOneOrders(@RequestHeader HttpHeaders headers, @Valid MobileVendorValidateOrderPageVO pageVO) {
        return mobileVendorOrderService.pageToValidateGradeOneOrders(headers, pageVO);
    }

    /**
     * “待审核订单（一级）” - 提交审核
     * @param headers Http头部信息
     * @param agreeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/grade/one", method = RequestMethod.POST)
    public Wrapper<Void> validateOrderGradeOne(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderAgreeVO agreeVO) {
        return mobileVendorOrderService.validateOrderGradeOne(headers, agreeVO);
    }

    /**
     * “待审核订单（二级）” - 查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/grade/two/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileVendorOrderQueryVO>> pageToValidateGradeTwoOrders(@RequestHeader HttpHeaders headers, @Valid MobileVendorValidateOrderPageVO pageVO) {
        return mobileVendorOrderService.pageToValidateGradeTwoOrders(headers, pageVO);
    }

    /**
     * “待审核订单（二级）” - 提交审核
     * @param headers Http头部信息
     * @param agreeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/grade/two", method = RequestMethod.POST)
    public Wrapper<Void> validateOrderGradeTwo(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderAgreeVO agreeVO) {
        return mobileVendorOrderService.validateOrderGradeTwo(headers, agreeVO);
    }

    /**
     * “待确认订单” - 查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/confirm/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileVendorOrderQueryVO>> pageToConfirmOrders(@RequestHeader HttpHeaders headers, @Valid MobileVendorValidateOrderPageVO pageVO) {
        return mobileVendorOrderService.pageToConfirmOrders(headers, pageVO);
    }

    /**
     * “待确认订单” - 确认
     * @param headers Http头部信息
     * @param agreeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/confirm", method = RequestMethod.POST)
    public Wrapper<Void> confirmOrder(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderAgreeVO agreeVO) {
        return mobileVendorOrderService.confirmOrder(headers, agreeVO);
    }
}
